package cn.edu.hznu.coursework.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.edu.hznu.coursework.entity.Course;
import cn.edu.hznu.coursework.entity.Student;

public interface StudentRepository extends JpaRepository<Student, Integer>{
	
	public Student findByNo(String no);
	
	public Student findByName(String name);
	
	@Query("SELECT s FROM Student s INNER JOIN s.courses c WHERE c IN (:courses)")
	public List<Student> findByCourses(@Param("courses") List<Course> courses);

}